package com.mpsc.lcn.consumer.service.impl;


import com.mpsc.api.bean.RoleInfoEntity;
import com.mpsc.lcn.consumer.dao.RoleInfoDao;
import com.mpsc.lcn.consumer.service.RoleInfoService;
import com.mpsc.lcn.consumer.webService.LcnRoleInfoService;
import com.mpsc.lcn.consumer.webService.ShardingRoleInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.UUID;

@Service
public class RoleInfoServiceImpl implements RoleInfoService {

    @Autowired
    private RoleInfoDao roleInfoDao;

    @Autowired
    private ShardingRoleInfoService shardingRoleInfoService;

    @Autowired
    private LcnRoleInfoService lcnRoleInfoService;

    @Override
    public void saveRoleInfo(RoleInfoEntity role) {
        System.out.println("--------------保存角色之前------------");
        roleInfoDao.saveRoleInfo(role);
        System.out.println("----------------通过feign调用findRole接口前---------------");
        lcnRoleInfoService.findRole();
        System.out.println("----------------通过feign调用findRole接口后---------------");

        System.out.println("----------------通过feign调用接口前---------------");
        lcnRoleInfoService.save(role);
        System.out.println("----------------通过feign调用接口后---------------");

        System.out.println("----------------通过feign调用findRoleById接口前---------------");
        lcnRoleInfoService.findRoleById(role.getId()+1);
        System.out.println("----------------通过feign调用findRoleById接口后---------------");
        //throw new RuntimeException("测试lcn回滚问题!!!");
        digui();
    }

    private void digui(){
        ArrayList list=new ArrayList();
        while(true) {
            list.add(UUID.randomUUID().toString().intern());
        }
    }

}
